﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Common.Lists;
    using System;

    public class CountryLists
    {
        public ListEntryInfo getCountryEntryInfo(string CountryCode, string Lang)
        {
            ListController controller = new ListController();
            string key = CountryCode;
            ListEntryInfoCollection listEntryInfoCollection = controller.GetListEntryInfoCollection("StoreCountry." + Lang);
            if (listEntryInfoCollection.Count == 0)
            {
                listEntryInfoCollection = controller.GetListEntryInfoCollection("Country");
                key = "Country:" + CountryCode;
            }
            else
            {
                key = "StoreCountry." + Lang + ":" + CountryCode;
            }
            return listEntryInfoCollection.Item(key);
        }

        public ListEntryInfoCollection getCountryList(string Lang)
        {
            ListController controller = new ListController();
            ListEntryInfoCollection listEntryInfoCollection = controller.GetListEntryInfoCollection("StoreCountry." + Lang);
            if (listEntryInfoCollection.Count == 0)
            {
                listEntryInfoCollection = controller.GetListEntryInfoCollection("Country");
            }
            return listEntryInfoCollection;
        }

        public string getCountryName(string Key, string Lang)
        {
            ListEntryInfo info = this.getCountryEntryInfo(Key, Lang);
            if (info == null)
            {
                return "";
            }
            return info.Text;
        }
    }
}

